﻿using System;

namespace Easy.Common.RegisterType
{
    [AttributeUsage(AttributeTargets.Interface | AttributeTargets.Class, AllowMultiple = false)]
    public class RegisterTypeAttribute : Attribute
    {
        public Type ImplementationType { get; private set; }

        public IocLifeTime IocLifetime { get; private set; }

        public InterceptorType InterceptorType { get; private set; }


        /// <summary>
        /// 为 类 和 接口 注册对应的实现类
        /// </summary>
        /// <param name="implementationType">实现类</param>
        /// <param name="iocLifetime">实现类的生命周期类型，默认为：New</param>
        /// <param name="interceptorType">实现类的拦截器类型，默认为：TransparentProxy</param>
        public RegisterTypeAttribute(Type implementationType, InterceptorType interceptorType = InterceptorType.None, IocLifeTime iocLifetime = IocLifeTime.New)
        {
            CheckHelper.NotNull(implementationType, "implementationType");

            this.ImplementationType = implementationType;

            this.IocLifetime = iocLifetime;

            InterceptorType = interceptorType;
        }
    }

}
